package com.huangd.platform.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    //交换机名称
    public static final String ITEM_TOPIC_EXCHANGE = "push";
    //队列名称
    public static final String ITEM_QUEUE = "push";

    // 声明注册交换机
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("push");
    }

    @Bean
    public Queue emailQueueDirect(){
        return new Queue("push",true);
    }

    //绑定队列和交换机
    @Bean
    public Binding bindingDirect(){
        return BindingBuilder.bind(emailQueueDirect()).to(directExchange()).with("push");
    }

}
